/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package TextManager;

/**
 *
 * @author Jaime
 */
public class WordOccurrence {
    
    private String content;
    
    public WordOccurrence(String content)
    {
        this.content = prepare(content);
        
        assert !this.content.contains(" ") : "Word with a space in the middle!";
        
    }

    @Override
    public int hashCode() {
        int hash = 3;
        hash = 37 * hash + (this.getContent() != null ? this.getContent().hashCode() : 0);
        return hash;
    }
    
    public boolean equals(Object anotherWord)
    {
        if(!(anotherWord instanceof WordOccurrence))
            return false;
        
        WordOccurrence another = (WordOccurrence)anotherWord;
        
        return another.getContent().equals(getContent());
        
    }
    
    public boolean isEmpty()
    {
        return getContent().isEmpty();
    }
    
    public boolean isNumberic()
    {
        return !content.isEmpty() && getContent().replaceAll("[0-9]", "").isEmpty();
    }
    
    public String toString()
    {
        return getContent();
    }

    private String prepare(String content) {
        return content.trim().toUpperCase();
    }

    /**
     * @return the content
     */
    public String getContent() {
        return content;
    }
    
}
